# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.

import numpy as np
import cv2 as cv
from my_camera import Camera
import time
from sorting_robot import SortingRobot


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    # img = cv.imread('/home/pi/Documents/Sorting/test/gird.png')
    # img = cv.imread('./test/gird.png')
    # images = [img]
    Robot = SortingRobot()
    # cam.set(cv.CAP_PROP_FRAME_WIDTH, 1280)
    # cam.set(cv.CAP_PROP_FRAME_HEIGHT, 720)

    Robot.activate_show_camera()

    while True:
        ret, frame = Robot.camera.read()
        if ret:
            cv.imshow('test', frame)
        if cv.waitKey(10) == ord('q'):
            break

    # a = cam.calibrate_intrinsic_matrix(images, 8, 6)
    # print(cam.in_mtx)
    #
    # obj_p = np.zeros((8 * 6, 3), np.float32)
    # obj_p[:, :2] = np.mgrid[0:8, 0:6].T.reshape(-1, 2)
    # a = cam.calibrate_extrinsic_matrix(img, 8, 6, obj_p)
    # print(a)

    cv.waitKey(0)
    cv.destroyAllWindows()
    Robot.camera.release()






